package com.jyw.router.cp.controller;

import com.jyw.router.common.annotation.Anonymous;
import com.jyw.router.common.core.domain.CommonResult;
import com.jyw.router.hospital.domain.vo.WxSendInputVo;
import com.jyw.router.hospital.service.IWxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author 沈峻
 * @ClassName WxMessageSend
 * @Description TODO
 * @Date 2023/4/24 14:02
 **/
@RestController
@Api(tags = "公众号消息推送")
@RequestMapping("wx/mp/message")
@Slf4j
public class WxMessageSendController {

    @Resource
    private IWxService wxService;

    /**
     * 工单转交
     * @param wxSendInputVo
     * @return
     */
    @PostMapping("/transfer")
    @ApiOperation("工单转交通知")
    @Anonymous
    public CommonResult transferTemplate(@ModelAttribute @Valid WxSendInputVo wxSendInputVo) {
        wxService.transferTemplate(wxSendInputVo);
        return CommonResult.success();
    }

    /**
     * 发送派单模版
     * @author 伍绍宇
     * @date 2021/04/29
     */
    @PostMapping("/assign")
    @ApiOperation(("派单通知"))
    @Anonymous
    public CommonResult assignTemplate(@ModelAttribute @Valid WxSendInputVo wxSendInputVo) {
        wxService.assignTemplate(wxSendInputVo);
        return CommonResult.success();
    }


    /**
     * 发送处理模版
     * @author 伍绍宇
     * @date 2021/04/29
     */
    @PostMapping("/make")
    @ApiOperation("工单处理")
    @Anonymous
    public CommonResult makeTemplate(@ModelAttribute WxSendInputVo wxSendInputVo) {
        wxService.makeTemplate(wxSendInputVo);
        return CommonResult.success();
    }

    /**
     * 工单受理通知
     * @author 沈峻
     * @date 2021/04/29
     */
    @PostMapping("/createOrder")
    @ApiOperation("工单受理通知")
    @Anonymous
    public CommonResult createOrder(@ModelAttribute WxSendInputVo wxSendInputVo) {
        wxService.createOrderTemplate(wxSendInputVo);
        return CommonResult.success();
    }

    /**
     * 发送派单通知
     * @author 沈峻
     * @date 2021/04/29
     */
    @PostMapping("/assist")
    @ApiOperation("派单通知")
    @Anonymous
    public CommonResult assist(@ModelAttribute WxSendInputVo wxSendInputVo) {
        wxService.assistTemplate(wxSendInputVo);
        return CommonResult.success();
    }

    /**
     * 项目、任务超时消息
     *
     */
    @PostMapping("/itemTimeOut")
    @ApiOperation("超时消息")
    @Anonymous
    public CommonResult itemTimeOut(@ModelAttribute WxSendInputVo wxSendInputVo) {
        wxService.itemTimeoutTemplate(wxSendInputVo);
        return CommonResult.success();
    }

    /**
     * 排班值班消息
     */
    @PostMapping("/schedule")
    @ApiOperation("值班消息")
    @Anonymous
    public CommonResult scheduleMsg(@ModelAttribute WxSendInputVo wxSendInputVo) {
        wxService.scheduleMsg(wxSendInputVo);
        return CommonResult.success();
    }

    /**
     * 通用消息推送
     * @param wxSendInputVo
     * @return Object
     * @author 沈峻
     * @date 2022年4月19日
     */
    @PostMapping("/commonSendMsg")
    @ApiOperation("通用消息")
    @Anonymous
    public CommonResult sendMsg(WxSendInputVo wxSendInputVo) {
        wxService.sendMessage(wxSendInputVo);
        return CommonResult.success();
    }

    @PostMapping("/commonSendMsg/test")
    @ApiOperation("通用消息测试")
    @Anonymous
    public CommonResult sendMsgTest(@RequestBody WxSendInputVo wxSendInputVo) {
        wxService.sendMessage(wxSendInputVo);
        return CommonResult.success();
    }


}
